package com.sakila.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

public class Film implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6896145344430271979L;
	
	private Integer id;
	private String title;
	private String description; //Be careful about the sql type
	private Integer releaseYear;
	private Language language;
	private Language orignalLanguage;
	private Integer rentalDuration;
	private Double rentalRate;
	private Integer length;
	private Double replacementCost;
	private String rating;
	private String specialFeatures;
	private Date lastUpdate;
	private Category category;
	private Set<Actor> actors = new LinkedHashSet<Actor>();
	
	public Film() {
		// TODO Auto-generated constructor stub
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getReleaseYear() {
		return releaseYear;
	}

	public void setReleaseYear(Integer releaseYear) {
		this.releaseYear = releaseYear;
	}

	public Language getLanguage() {
		return language;
	}

	public void setLanguage(Language language) {
		this.language = language;
	}

	public Language getOrignalLanguage() {
		return orignalLanguage;
	}

	public void setOrignalLanguage(Language orignalLanguage) {
		this.orignalLanguage = orignalLanguage;
	}

	public Integer getRentalDuration() {
		return rentalDuration;
	}

	public void setRentalDuration(Integer rentalDuration) {
		this.rentalDuration = rentalDuration;
	}

	public Double getRentalRate() {
		return rentalRate;
	}

	public void setRentalRate(Double rentalRate) {
		this.rentalRate = rentalRate;
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public Double getReplacementCost() {
		return replacementCost;
	}

	public void setReplacementCost(Double replacementCost) {
		this.replacementCost = replacementCost;
	}

	public String getRating() {
		return rating;
	}

	public void setRating(String rating) {
		this.rating = rating;
	}

	public String getSpecialFeatures() {
		return specialFeatures;
	}

	public void setSpecialFeatures(String specialFeatures) {
		this.specialFeatures = specialFeatures;
	}

	public Date getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public Set<Actor> getActors() {
		return actors;
	}

	public void setActors(Set<Actor> actors) {
		this.actors = actors;
	}
	
	public void addActor(Actor actor){
		actor.addFilm(this);
		this.actors.add(actor);
	}
	
	public void removeActor(Actor actor){
		actor.addFilm(null);
		this.actors.remove(actor);
	}
	
	public String showActors(){
		StringBuilder sBuilder = new StringBuilder();
		if(actors.isEmpty()){
			sBuilder.append("No actor available now");
		}else {
			int temp = 0;
			for(Actor actor : actors){
				if(temp < actors.size() - 1){
					sBuilder.append(actor.getName() + ", ");
				}else {
					//if last object
					sBuilder.append(actor.getName());
				}
				temp++;
			}
		}
		return sBuilder.toString();
	}
}
